package com.hfut.jpoa.service.impl;

import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import com.hfut.jpoa.common.dto.ResultDto;
import com.hfut.jpoa.dao.ProviderDAO;
import com.hfut.jpoa.dto.ProviderDTO;
import com.hfut.jpoa.model.Provider;
import com.hfut.jpoa.service.ProviderService;
import com.hfut.jpoa.service.exception.ProviderException;

public class ProviderServiceImpl implements ProviderService {

	private static final Logger LOGGER = LoggerFactory
			.getLogger(ProviderServiceImpl.class);

	private ProviderDAO providerDAO;



	

	public Provider findProvider(long id) throws ProviderException {
		// TODO Auto-generated method stub
		return null;
	}



	

	public List<Provider> getProvider(String key) throws ProviderException {
		// TODO Auto-generated method stub
		return null;
	}



	

	public ResultDto<Provider> queryProviderInfoForPage(
			ProviderDTO systemConfigDTO) throws ProviderException {
		// TODO Auto-generated method stub
		return null;
	}



	

	public List<Provider> selectProviderInfo(Provider Provider)
			throws ProviderException {
		// TODO Auto-generated method stub
		return null;
	}



	

	public void insertSystemConfig(Provider systemConfig)
			throws ProviderException {
		// TODO Auto-generated method stub

	}



	

	public void updateSystemConfig(Provider systemConfig)
			throws ProviderException {
		// TODO Auto-generated method stub

	}



	

	public List<Provider> selectSameSysConfig() throws ProviderException {
		// TODO Auto-generated method stub
		return null;
	}

	
	public void batchUpdateIndex(List<String> sameIdTypeList)
			throws ProviderException {
		// TODO Auto-generated method stub

	}

	
	public ResultDto<Provider> list(ProviderDTO providerDTO)
			throws ProviderException {

		return providerDAO.findProviderInfoForPage(providerDTO);
	}

	
	public ResultDto<Provider> queryCategoryInfoForPage(ProviderDTO categoryDTO)
			throws ProviderException {
		return providerDAO.findProviderInfoForPage(categoryDTO);
	}

	public Provider findProviderInfo(Provider record) throws ProviderException {
		
		if (null == record && StringUtils.isBlank(record.getId())) {
			LOGGER.error("selectProviderInfo异常：值为空 ");
			throw new ProviderException("selectProviderInfo异常：值为空 ");
		}

		Provider result = providerDAO.selectByPrimaryKey(record.getId());

		return result;
	}

	
	public void saveProvider(Provider record) throws ProviderException {
		if (null == record) {
			LOGGER.error("provider is empty.");
			throw new ProviderException("provider info is not complete");
		}

		providerDAO.insert(record);

	}

	
	public void updateProvider(Provider record) throws ProviderException {
		if (null == record) {
			LOGGER.error("provider is empty.");
			throw new ProviderException("provider info is not complete");
		}

		providerDAO.updateByPrimaryKeySelective(record);
	}

	public void setProviderDAO(ProviderDAO providerDAO) {
		this.providerDAO = providerDAO;
	}

}
